<?php
$debug=false;
if ($debug){
	error_reporting(E_ALL);
	ini_set('display_errors', '1');
}

function checkuser($tip){
	$query  = "CALL checkuser('".$_SESSION['username']."','".$tip."',@ab);SELECT @ab;";
	$aa=0;
		if (MyDatabase::getConnection()->multi_query($query)) {
			do {
				/* store first result set */
				if ($result = MyDatabase::getConnection()->store_result()) {
					while ($row = $result->fetch_row()) {
						$aa=$row[0];
					}
					$result->free();
				}

			} while (MyDatabase::getConnection()->more_results() && MyDatabase::getConnection()->next_result());
		}
return $aa;
}

function checklogin($u){
	$query  = "CALL login('".$u."',@ab);SELECT @ab;";
		$aa=0;
		if (MyDatabase::getConnection()->multi_query($query)) {
			do {
				
				if ($result = MyDatabase::getConnection()->store_result()) {
					while ($row = $result->fetch_row()) {
						$aa=$row;
					}
					$result->free();
				}

			} while (MyDatabase::getConnection()->more_results() && MyDatabase::getConnection()->next_result());
		}
		else{
			$_SESSION['uzenet']=   MyDatabase::getConnection()->error;
		}
return $aa;
}

function egyenleg($u){
	$query  = "CALL egyenleg('".$u."',@ab);SELECT @ab;";
		$aa=0;
		if (MyDatabase::getConnection()->multi_query($query)) {
			do {
				
				if ($result = MyDatabase::getConnection()->store_result()) {
					while ($row = $result->fetch_row()) {
						$aa=$row;
					}
					$result->free();
				}

			} while (MyDatabase::getConnection()->more_results() && MyDatabase::getConnection()->next_result());
		}
		else{
			$_SESSION['uzenet']=   MyDatabase::getConnection()->error;
		}
return $aa;
}

function useredit($u){
	$ret;
	if ($u=="")
		return;
	$query="CALL useredit('".$u."');";
				if (MyDatabase::getConnection()->multi_query($query)) {
					do {
						if ($result = MyDatabase::getConnection()->store_result()) {
							while ($row = $result->fetch_row()) {
								$ret = $row;
							}
							$result->free();
						}

					} while (MyDatabase::getConnection()->more_results() && MyDatabase::getConnection()->next_result());
				}
				else{
					$_SESSION['uzenet']=   MyDatabase::getConnection()->error;
				}
				return $ret;
}

function termenyedit($u){
	$ret;
	if ($u=="")
		return;
	$query="CALL termenyedit('".$u."');";
				if (MyDatabase::getConnection()->multi_query($query)) {
					do {
						if ($result = MyDatabase::getConnection()->store_result()) {
							while ($row = $result->fetch_row()) {
								$ret = $row;
							}
							$result->free();
						}

					} while (MyDatabase::getConnection()->more_results() && MyDatabase::getConnection()->next_result());
				}
				else{
					$_SESSION['uzenet']=   MyDatabase::getConnection()->error;
				}
				return $ret;
}

function mertekegysegedit($u){
	$ret;
	if ($u=="")
		return;
	$query="CALL mertekegysegedit('".$u."');";
				if (MyDatabase::getConnection()->multi_query($query)) {
					do {
						if ($result = MyDatabase::getConnection()->store_result()) {
							while ($row = $result->fetch_row()) {
								$ret = $row;
							}
							$result->free();
						}

					} while (MyDatabase::getConnection()->more_results() && MyDatabase::getConnection()->next_result());
				}
				else{
					$_SESSION['uzenet']=   MyDatabase::getConnection()->error;
				}
				return $ret;
}

function firstkey($array1){
	foreach($array1 as $key=>$value)
	{
	  return "$key";
	}
}

?>